package com.example.liuapplication;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

//注解Dao
@Dao
public interface EmperorDao {

    //插入数据
    @Insert
    public void insertEmperor(Emperor... emperor);


    //删除数据
    @Delete
    public void deleteEmperor(Emperor... emperor);

    @Query("DELETE FROM emperor_table")
    void deleteAll();



    //修改数据
    @Update
    public void updateEmperor(Emperor... emperor);


    //根据条件查询唯一的一个
    @Query("SELECt * FROM emperor_table WHERE id=:id")
    public Emperor queryEmperorById(int id);

    //根据条件查询多个数据
    @Query("SELECt * FROM emperor_table WHERE emperor_name=:name and age=:age  and height=:height  and gender=:gender  and weight=:weight ")
    public List<Emperor> queryEmperorByAnd(String name, String age, String height, String gender, String weight);

    //根据条件查询多个数据
    @Query("SELECt * FROM emperor_table WHERE emperor_name=:name or age=:age  or height=:height  or gender=:gender  or weight=:weight ")
    public List<Emperor> queryEmperorsByOr(String name, String age, String height, String gender, String weight);


    //不设置条件，查询所有数据
    @Query("SELECt * FROM emperor_table")
    public List<Emperor> queryEmperors();
}

